#!/bin/bash
#
# Devstack settings

# Each service you enable has the following meaning:
# odl-neutron - Add this config flag if OpenDaylight controller and OpenStack
#               Controller are on different nodes.
# odl-server  - Add this config flag if OpenDaylight controller and OpenStack
#               Controller are on the same node.
# odl-compute - Add this config flag for OpenStack Compute.
#
# odl-lightweight-testing - Add this config flag for testing neutron ODL ML2
#                           driver and networking-odl without a real running
#                           OpenDaylight instance
#
# NOTE: odl-server includes odl-neutron.
#
# An example of enabling all-in-one ODL is below.
#enable_service odl-compute odl-server

# This can be overridden in the localrc file
ODL_MODE=${ODL_MODE:-allinone}

# ODL_MODE is used to configure how devstack works with OpenDaylight. You
# can configure this three ways:
#
# ODL_MODE=allinone
# Use this mode if you want to run ODL in this devstack instance. Useful
# for a single node deployment or on the control node of a multi-node
# devstack environment.
#
# ODL_MODE=compute
# Use this for the compute nodes of a multi-node devstack install.
#
# ODL_MODE=externalodl
# This installs the neutron code for ODL, but does not attempt to
# manage ODL in devstack. This is used for development environments
# similar to the allinone case except where you are using bleeding edge ODL
# which is not yet released, and thus don't want it managed by
# devstack.
#
# ODL_MODE=lightweight-testing
# Use this for testing neutron ML2 driver plus networking-odl without
# a running OpenDaylight instance.
#
# ODL_MODE=manual
# You're on your own here, and are enabling services outside the scope of
# the ODL_MODE variable.

case $ODL_MODE in
    allinone)
        enable_service odl-server odl-compute
        ;;
    externalodl)
        enable_service odl-neutron odl-compute
        ;;
    compute)
        enable_service odl-compute
        ;;
    lightweight-testing)
        enable_service odl-lightweight-testing
        ;;
    manual)
        echo "Manual mode: Enabling services explicitly."
        ;;
esac


IS_GATE=$(trueorfalse False IS_GATE)
if [[ "$IS_GATE" == "True" ]]; then
    NETWORKING_ODL_DIR=${NETWORKING_ODL_DIR:-$DEST/networking-odl}
fi

# in tempest.conf
# [networking-feature-enabled] api-extensions
# api-extensions=all means any kind of extensions is enabled irrelevant of
# what plugin supports ML2 plugin with ODL driver supports only the following
# extensions, not all Those list must be maintained as ML2 plugin
# with ODL driver supports more extensions
if [[ -z "$NETWORK_API_EXTENSIONS" ]]; then
    NETWORK_API_EXTENSIONS=address-scope
    NETWORK_API_EXTENSIONS+=,agent
    NETWORK_API_EXTENSIONS+=,allowed-address-pairs
    NETWORK_API_EXTENSIONS+=,binding
    NETWORK_API_EXTENSIONS+=,dhcp_agent_scheduler
    NETWORK_API_EXTENSIONS+=,dvr
    NETWORK_API_EXTENSIONS+=,ext-gw-mode
    NETWORK_API_EXTENSIONS+=,external-net
    NETWORK_API_EXTENSIONS+=,extra_dhcp_opt
    NETWORK_API_EXTENSIONS+=,extraroute
    NETWORK_API_EXTENSIONS+=,flavors
    NETWORK_API_EXTENSIONS+=,multi-provider
    NETWORK_API_EXTENSIONS+=,net-mtu
    NETWORK_API_EXTENSIONS+=,network-ip-availability
    NETWORK_API_EXTENSIONS+=,pagination
    NETWORK_API_EXTENSIONS+=,port-security
    NETWORK_API_EXTENSIONS+=,project-id
    NETWORK_API_EXTENSIONS+=,provider
    NETWORK_API_EXTENSIONS+=,qos
    NETWORK_API_EXTENSIONS+=,quotas
    NETWORK_API_EXTENSIONS+=,rbac-policies
    NETWORK_API_EXTENSIONS+=,router
    NETWORK_API_EXTENSIONS+=,router-interface-fip
    NETWORK_API_EXTENSIONS+=,security-group
    NETWORK_API_EXTENSIONS+=,service-type
    NETWORK_API_EXTENSIONS+=,sorting
    NETWORK_API_EXTENSIONS+=,standard-attr-description
    NETWORK_API_EXTENSIONS+=,standard-attr-revisions
    NETWORK_API_EXTENSIONS+=,standard-attr-timestamp
    NETWORK_API_EXTENSIONS+=,subnet_allocation
    NETWORK_API_EXTENSIONS+=,tag
    NETWORK_API_EXTENSIONS+=,timestamp_core
    NETWORK_API_EXTENSIONS+=,vlan-transparent
fi
